package com.lwlk.zdk.controller.Enterprise;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lwlk.zdk.annotation.JwtIgnore;
import com.lwlk.zdk.annotation.MyLog;
import com.lwlk.zdk.controller.Vehicle.VehicleController;
import com.lwlk.zdk.enums.RetCode;
import com.lwlk.zdk.mapper.T.*;
import com.lwlk.zdk.mapper.pw.pwUserMapper;
import com.lwlk.zdk.mapper.sys.sysEnterpriseMapper;
import com.lwlk.zdk.mapper.wd.wdHfAreaMapper;
import com.lwlk.zdk.mapper.wd.wdIndustryDictionaryMapper;
import com.lwlk.zdk.model.CommonAreaModel;
import com.lwlk.zdk.model.CommonUser;
import com.lwlk.zdk.model.T.TDisDictionary;
import com.lwlk.zdk.model.T.TDisEnterprise;
import com.lwlk.zdk.model.T.TDisEnterprisePlatform;
import com.lwlk.zdk.model.T.TDisVehicle;
import com.lwlk.zdk.service.EnterpriseService.EnterpriseService;
import com.lwlk.zdk.service.wd.DictionaryService;
import com.lwlk.zdk.service.wdHfArea.AreaService;
import com.lwlk.zdk.util.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.xml.crypto.Data;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

@RestController
@Transactional
@RequestMapping(value = "/enterprise")
public class EnterpriseController {

    private final static String port = PropUtils.getString("ports");
    private final static String Ip = PropUtils.getString("Ip");
    private final static String clientCode = PropUtils.getString("clientCode");

    private static final Logger log = LoggerFactory.getLogger(EnterpriseController.class);

    @Autowired
    DictionaryService dictionaryService;
    @Autowired
    TDisEnterpriseMapper tDisEnterpriseMapper;
    @Autowired
    TDisPlatformMapper tDisPlatformMapper;
    @Autowired
    TDisStaffMapper tDisStaffMapper;
    @Autowired
    TDisDictionaryMapper tDisDictionaryMapper;
    @Autowired
    TRegionMapper tRegionMapper;
    @Autowired
    TDisEnterprisePlatformMapper disEnterprisePlatformMapper;
    @Autowired
    TDisVehicleMapper tDisVehicleMapper;
    @Autowired
    TDisDictionaryMapper disDictionaryMapper;
    @Autowired
    pwUserMapper pwUserMapper;


    @ApiOperation(value = "添加企业信息")
    @MyLog(value = "添加企业信息")  //这里添加了AOP的自定义注解
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Response add(@RequestBody TDisEnterprise disEnterprise,HttpServletRequest request){
        Response response=new Response();
        try {
            boolean flag= listerUtil.getLister(request);
            if (flag==false){
                response.setCode(RetCode.ACCOUNT_EXIST);
                response.setMsg("此账号为监管员账号,不可进行操作");
                return response;
            }
             Integer enterpriseId=tDisEnterpriseMapper.selectMaxEnterpriseId()+1;
             disEnterprise.setEnterpriseId(enterpriseId);
             disEnterprise.setSource(1);
             disEnterprise.setCreateDate(new Date());
             disEnterprise.setDelFlag((short) 1);
             int count=tDisEnterpriseMapper.insertSelective(disEnterprise);
             response.setData(count);
             response.setMsg("执行成功");
             response.setCode(RetCode.SUCCESS);

        }catch (Exception e){
            e.printStackTrace();
        }
        return response;
    }
    @ApiOperation(value = "管辖机构名称")
    @RequestMapping(value = "/showOrganizationId",method = RequestMethod.GET)
    public Response getOrganizationId(Integer regionId){
        Response response=new Response();
        List<Map<String, Object>> regionList = tRegionMapper.selectByArea(regionId);
        response.setData(regionList);
        response.setCode(RetCode.SUCCESS);
        response.setMsg("执行成功");
        return response;
    }

    @ApiOperation(value = "企业名称不可相同")
    @RequestMapping(value = "/is_exist_EnterpriseName",method = RequestMethod.GET)
    public Response getEnterprise(String enterpriseName){
        Response response=new Response();
        int i=tDisEnterpriseMapper.selectManyVehicleNumber(enterpriseName);
        if (i>0){
            response.setCode(RetCode.ENTERPRISE_EXIST);
        }else {
            response.setCode(RetCode.USABLE_SUCCESS);
        }
        return response;
    }


    @ApiOperation(value = "修改企业信息")
    @MyLog(value = "修改企业信息")  //这里添加了AOP的自定义注解
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Response update(@RequestBody TDisEnterprise disEnterprise,HttpServletRequest request){
        Response response=new Response();
        try {
            boolean flag= listerUtil.getLister(request);
            if (flag==false){
                response.setCode(RetCode.ACCOUNT_EXIST);
                response.setMsg("此账号为监管员账号,不可进行操作");
                return response;
            }
            Boolean flage= listerUtil.getRegionCode(request,disEnterprise);
            if (flag==false){
                response.setCode(RetCode.ACCOUNT_EXIST);
                response.setMsg("不可修改账号所属地区以外的信息");
                return response;
            }
            int i=tDisEnterpriseMapper.updateByPrimaryKeySelective(disEnterprise);
            response.setData(i);
            response.setCode(RetCode.SUCCESS);
            response.setMsg("执行成功");
        }catch (Exception e){
            e.printStackTrace();
        }
        return  response;
    }


    @ApiOperation(value = "批量删除企业信息")
    @MyLog(value = "批量删除企业信息")  //这里添加了AOP的自定义注解
    @RequestMapping(value = "/deleteBatch",method = RequestMethod.POST)
    public Response deleteBatch(Integer[] ids){
        Response response=new Response();
        try {

            for (Integer id : ids) {
                int i=tDisEnterpriseMapper.deleteByPrimaryKey(id);
            }
            response.setMsg("执行成功");
            response.setData(1);
            response.setCode(RetCode.SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
        }
        return response;
    }




    @ApiOperation(value = "批量删除企业信息(逻辑删除)")
    @MyLog(value = "批量删除企业信息(逻辑删除)")
    @RequestMapping(value = "/logicallyDeleteBatch",method = RequestMethod.POST)
    public Response getLogicallyDeleteBatch(Integer[] ids){
        Response response=new Response();
        try {
            for (Integer id : ids) {
                int i=tDisEnterpriseMapper.logicallyDeleteBatch(id);
            }
            response.setMsg("执行成功");
            response.setData(1);
            response.setCode(RetCode.SUCCESS);
        }catch (Exception e){
            e.printStackTrace();
        }
        return response;
    }

    @ApiOperation(value = "删除企业信息")
    @MyLog(value = "删除企业信息")  //这里添加了AOP的自定义注解
    @RequestMapping(value = "/logicallyDelete",method = RequestMethod.POST)
    public Response getLogicallyDelete(Integer id,HttpServletRequest request){
        Response response=new Response();
        TDisEnterprise disEnterprise=tDisEnterpriseMapper.selectByPrimaryKey(id);
        boolean flag= listerUtil.getLister(request);
        if (flag==false){
            response.setCode(RetCode.ACCOUNT_EXIST);
            response.setMsg("此账号为监管员账号,不可进行操作");
            return response;
        }
        Boolean flage= listerUtil.getRegionCode(request,disEnterprise);
        if (flag==false){
            response.setCode(RetCode.ACCOUNT_EXIST);
            response.setMsg("不可修改账号所属地区以外的信息");
            return response;
        }
        int count=tDisEnterpriseMapper.deleteByPrimaryKey(id);
        response.setMsg("执行成功");
        response.setData(count);
        response.setCode(RetCode.SUCCESS);
        return response;
    }

    @ApiOperation(value = "业户信息删除")
    @MyLog(value = "删除企业信息")  //这里添加了AOP的自定义注解
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public Response delete(Integer id,HttpServletRequest request){
        Response response=new Response();
        try {
            TDisEnterprise disEnterprise=tDisEnterpriseMapper.selectByPrimaryKey(id);
            boolean flag= listerUtil.getLister(request);
            if (flag==false){
                response.setCode(RetCode.ACCOUNT_EXIST);
                response.setMsg("此账号为监管员账号,不可进行操作");
                return response;
            }
            Boolean flage= listerUtil.getRegionCode(request,disEnterprise);
            if (flag==false){
                response.setCode(RetCode.ACCOUNT_EXIST);
                response.setMsg("不可修改账号所属地区以外的信息");
                return response;
            }
            int count=tDisEnterpriseMapper.deleteByPrimaryKey(id);
            int i=disEnterprisePlatformMapper.deleteByEnterpriseId(id);
            response.setData(count);
            response.setCode(RetCode.SUCCESS);
            response.setMsg("执行成功");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return response;
    }




    @ApiOperation(value = "业户信息展示(模糊查询,根据业户名)")
    @RequestMapping(value = "/showDim",method = RequestMethod.GET)
    public LayuiTablePagingResult showDim(Integer areaCode,String enterpriseName,Integer page,Integer size,Integer level){
      LayuiTablePagingResult result=null;
        PageHelper.startPage(page,size);
          List<Map<String,Object>> enterpriseList=tDisEnterpriseMapper.selectAll(enterpriseName);
          for (int i = 0; i <enterpriseList.size(); i++) {
              Map map=enterpriseList.get(i);
              Integer areaCodeName=Integer.parseInt(String.valueOf(map.get("regionCode")));
              String industry=String.valueOf(map.get("industryId"));
              String scope=String.valueOf(map.get("scope"));
              //字典表查询行业
              String industryName=tDisDictionaryMapper.selectIndustryId(industry);
              String code=tRegionMapper.selectAreaCode(areaCodeName);
              enterpriseList.get(i).put("areaCode",code);
              enterpriseList.get(i).put("netStatus","已入网");
              enterpriseList.get(i).put("industry",industryName);
              enterpriseList.get(i).put("scope", scope);
          }
          PageInfo pageInfo=new PageInfo<>(enterpriseList);
          result = new LayuiTablePagingResult();
          result.setCode(RetCode.SUCCESS.getCode());
          result.setMsg(RetCode.SUCCESS.getMsg());
          result.setCount(pageInfo.getTotal());
          result.setData(pageInfo.getList());
          Long totalPages = pageInfo.getTotal() / size;
          if (pageInfo.getTotal() % size != 0){
              totalPages ++;
          }
          result.setTotalPages(totalPages);
      return result;
    }

    @Transactional (propagation= Propagation.REQUIRED,isolation= Isolation.DEFAULT,readOnly=false)
    @ApiOperation(value = "绑定平台(接入业户)")
    @RequestMapping(value = "/bindingPlatform",method = RequestMethod.GET)
    public Response getBindingPlatform(Integer platformId, Integer enterpriseId, HttpServletRequest request){
        Response response=new Response();
        TDisEnterprisePlatform disEnterprisePlatform=new TDisEnterprisePlatform();
        disEnterprisePlatform.setEnterpriseId(enterpriseId);
        disEnterprisePlatform.setPlatformId(platformId);
        int count=disEnterprisePlatformMapper.selectOne(disEnterprisePlatform);
        int i;
        if (count==0){
             i=disEnterprisePlatformMapper.insert(disEnterprisePlatform);
        }else {
             i=disEnterprisePlatformMapper.updatePlatform(disEnterprisePlatform);
        }
        response.setCode(RetCode.SUCCESS);
        response.setMsg("执行成功");
        response.setData(i);
        return response;
    }



    @ApiOperation(value = "展示平台信息")
    @RequestMapping(value = "/showPlatform",method = RequestMethod.GET)
    public Response getShowPlatform(Integer level,Integer platformCode){
        Response response=new Response();
        Integer regionCode=null;
        if (level==1){
            regionCode= Integer.valueOf(String.valueOf(platformCode).substring(0,2));
        }else if (level==2){
            regionCode= Integer.valueOf(String.valueOf(platformCode).substring(0,4));
        }else if (level==3){
            regionCode= platformCode;
        }
        List<Map<String,Object>>platformList=tDisPlatformMapper.selectPlatformList();
        response.setData(platformList);
        response.setCode(RetCode.SUCCESS);
        response.setMsg("执行成功");
        return response;
    }

    @ApiOperation(value = "业户信息详情")
    @RequestMapping(value = "/enterpriseDetails",method = RequestMethod.GET)
    public Response enterpriseDetails(Integer enterpriseId) throws ParseException {
        Response response=new Response();
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        List<Map<String,Object>>enterprise=tDisEnterpriseMapper.selectDetails(enterpriseId);
        Map map=enterprise.get(0);
        Integer areaCodeName=Integer.parseInt(String.valueOf(map.get("regionCode")));
        String businessCertificateDate = null;
        if (map.get("loseEfficacyDate")!=null){
             businessCertificateDate=sdf.format(sdf.parse(String.valueOf(map.get("businessCertificateDate"))));//经营许可证发证日期
        }
        String startValidDate= null;
        if (map.get("loseEfficacyDate")!=null){
             startValidDate=sdf.format(sdf.parse(String.valueOf(map.get("startValidDate"))));//经营许可证有效起始日期
        }
        String loseEfficacyDate=null;
        if (map.get("loseEfficacyDate")!=null){
             loseEfficacyDate=sdf.format(sdf.parse(String.valueOf(map.get("loseEfficacyDate"))));//经营许可证有效终止日期
        }

        String organizationName;
        if (map.get("organizationId")!=null){
            Integer organizationId=Integer.parseInt(String.valueOf(map.get("organizationId")));
             organizationName=tRegionMapper.selectByoId(organizationId);
        }else {
             organizationName=null;
        }

        String industry=String.valueOf(map.get("industryId"));
        String scope=String.valueOf(map.get("scope"));
/*        String[] scopeAll=scope.split(",");
        String scopeName="";
        for (String s : scopeAll) {
            String itemName=tDisDictionaryMapper.selectDgName(s);
            scopeName=scopeName+itemName+",";
        }*/
        //scopeAll=scopeName.split(",");
        //字典表查询行业

        String industryName=tDisDictionaryMapper.selectIndustryId(industry);
        String code=tRegionMapper.selectAreaCode(areaCodeName);
        enterprise.get(0).put("areaCode",code);
        enterprise.get(0).put("industry",industryName);
        enterprise.get(0).put("organizationName",organizationName);
        enterprise.get(0).put("scopeName", scope);
        enterprise.get(0).put("businessCertificateDate", businessCertificateDate);
        enterprise.get(0).put("startValidDate", startValidDate);
        enterprise.get(0).put("loseEfficacyDate", loseEfficacyDate);
        response.setData(enterprise);
        response.setCode(RetCode.SUCCESS);
        return response;
    }


    @ApiOperation(value = "所属地区")
    @RequestMapping(value = "/affiliatingArea",method = RequestMethod.GET)
    public Response getAffiliatingArea(Integer parentId){
        Response response=new Response();
        //查询省管辖的市
        List<CommonAreaModel> areaList=tRegionMapper.selectArea(parentId);
        response.setCode(RetCode.SUCCESS);
        response.setData(areaList);
        return response;
    }

    @ApiOperation(value = "所属地区首页使用")
    @RequestMapping(value = "/HomeRegion",method = RequestMethod.GET)
    public Response getHomeRegion(Integer parentId){
        Response response=new Response();
        //查询平台管辖的地区
        List areaList=tRegionMapper.selectAreaHomeRegion(parentId);
        response.setCode(RetCode.SUCCESS);
        response.setData(areaList);
        return response;
    }


    //=======展示所属地区码及其所属行业经营范围(根据地区Code的id查询-----业户新增页面-------)================
    @ApiOperation(value = "展示所属地区码及其所属行业经营范围(根据地区Code的id查询)")
    @RequestMapping(value = "/showArea",method = RequestMethod.GET)
    public Response showArea(){
      Response response=new Response();
      try {
          HashMap map=new HashMap();
             //查询中国的所有的省
             List areasList=tRegionMapper.selectPid();
             //企业经营范围
             List<TDisDictionary>wdIndustryDictionaryList=tDisDictionaryMapper.selectBusinessScope();
             List<Map<String,Object>>industryTypeList=new LinkedList<>();
             Map map1=new HashMap();
             map1.put("itemName","班车客运");
             map1.put("itemValue","11");
            Map map2=new HashMap();
            map2.put("itemName","包车客运");
            map2.put("itemValue","12,13,14");
            Map map3=new HashMap();
            map3.put("itemName","危货运输");
            map3.put("itemValue","30,31,32");
          industryTypeList.add(map3);
          industryTypeList.add(map1);
          industryTypeList.add(map2);



             //所属行业
              //List<TDisDictionary>industryTypeList=tDisDictionaryMapper.selectIndustryType();
             map.put("所属地区",areasList);
             map.put("经营范围",wdIndustryDictionaryList);
             map.put("所属行业",industryTypeList);
             response.setCode(RetCode.SUCCESS);
             response.setData(map);

      }catch (Exception e){
          e.printStackTrace();
      }
      return response;
    }

    //=======车辆新增展示数据(所属地区,业户名称,车辆类型,车牌颜色,所属行业-----车辆新增页面------)================
    @ApiOperation(value = "车辆新增展示数据(所属地区,业户名称,车辆类型,车牌颜色,所属行业)")
    @RequestMapping(value = "/showIndustry",method = RequestMethod.GET)
    public Response showIndustry(String AreaId){
        Response response=new Response();
        try {
            if (AreaId==null){
                //中国省份名称和code
                List areasList=tRegionMapper.selectPid();
                String industryType="industry_type";
                //所属行业
                List<Map<String,Object>>industry=tDisDictionaryMapper.selectIndustry(industryType);
                //车辆类型
                String vehicleType="vehicle_type";
                List<Map<String, Object>> maps = tDisDictionaryMapper.selectIndustry(vehicleType);
                //车牌颜色
                String vehicleColor="vehicle_color";
                List<Map<String, Object>> mapList = tDisDictionaryMapper.selectIndustry(vehicleColor);

            /*    for (int i = 0; i < industry.size(); i++) {
                    Map map=industry.get(i);
                    Object itemType =map.get("itemValue");
                    String substring = itemType.toString().substring(1, 3);
                    response.setData(substring);
                }*/
            HashMap map=new HashMap();
            map.put("所属行业",industry);
            map.put("所属地区",areasList);
            map.put("车辆类型",maps);
            map.put("车牌颜色",mapList);
            response.setData(map);
            response.setCode(RetCode.SUCCESS);
            response.setMsg("执行成功");
            }else {//查询省管辖的市
                List areaList=tRegionMapper.selectById(AreaId);
                response.setCode(RetCode.SUCCESS);
                response.setData(areaList);
                response.setMsg("执行成功");
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return response;
    }

    @ApiOperation(value = "展示所有企业")
    @RequestMapping(value = "/showAllEnterprise",method = RequestMethod.GET)
    public LayuiTablePagingResult getShowAllEnterprise(Integer page,Integer size,String enterpriseName,Integer areaCode,Integer level){
        LayuiTablePagingResult result=null;
        PageHelper.startPage(page,size);
        Integer regionCode=null;
        if (level==1){
            regionCode= Integer.valueOf(String.valueOf(areaCode).substring(0,2));
        }else if (level==2){
            regionCode= Integer.valueOf(String.valueOf(areaCode).substring(0,4));
        }else if (level==3){
            regionCode= areaCode;
        }
        //业户名称
        List<Map<String,Object>>enterpriseNameList=tDisEnterpriseMapper.selectEnterpriseName(enterpriseName,regionCode);
        PageInfo pageInfo = new PageInfo(enterpriseNameList);
        result = new LayuiTablePagingResult();
        result.setCode(RetCode.SUCCESS.getCode());
        result.setMsg(RetCode.SUCCESS.getMsg());
        result.setCount(pageInfo.getTotal());
        result.setData(pageInfo.getList());
        Long totalPages = pageInfo.getTotal() / size;
        if (pageInfo.getTotal() % size != 0){
            totalPages ++;
        }
        result.setTotalPages(totalPages);
        return result;
    }



    @ApiOperation(value = "展示驾驶员身份")
    @RequestMapping(value = "/driver",method = RequestMethod.POST)
    public JSONObject getDriver(String page,String limit,String regionCode,String vehicleNumber){
            String vIdlist="";
            String vIds=null;
            if (vehicleNumber!=null && vehicleNumber.equals("")==false){
                List<Map> vehicleNumberList=tDisVehicleMapper.selectVehicleId(vehicleNumber);
                if (vehicleNumberList.size()>0){
                    for (int i = 0; i < vehicleNumberList.size(); i++) {
                        vIdlist=vIdlist+vehicleNumberList.get(i).get("vehicle_id")+",";
                    }
                    vIds= StringUtils.join(vIdlist.split(","),",");
                }else {
                    String list="{\"code\":1001,\"msg\":\"接口执行成功\",\"result\":{\"currPage\":1,\"list\":[],\"pageSize\":0,\"totalCount\":0,\"totalPage\":0}}";
                    return JSONObject.parseObject(list);
                }
            }
            Map map=new HashMap();
            map.put("vIds",vIds);//车辆id
            map.put("limit",limit);//必选 页面记录数，默认为10
            map.put("page",page);//必选 页码，默认为1
            map.put("regionCode",regionCode);//必选 登录用户所属的机构所在地区行政区划代码
            Set<String> set = map.keySet();
            Iterator<String> it = set.iterator();
            while (it.hasNext()) {
                String str = it.next();
                if(map.get(str)==null || map.get(str) =="null"|| map.get(str)==""){
                    map.remove(str);
                    set = map.keySet();
                    it = set.iterator();
                }
            }
            Map<String,String>headMap=new HashMap<>();
            headMap.put("clientCode",clientCode);
            String url="http://"+Ip+":"+port+"/dis/business/driver/driverReport";
            String result=HttpClientUtils.doGet(url,headMap,map);
            JSONObject json= JSONObject.parseObject(result);
            JSONObject jo=json.getJSONObject("result");
            JSONArray jsonArray=jo.getJSONArray("list");
            if (jsonArray==null){
                return json;
            }
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject jsonObject=jsonArray.getJSONObject(i);
                String color=jsonObject.getString("color");//平台id
                Integer regionId= Integer.valueOf(jsonObject.getString("regionCode"));//地区码
                String regionName=tRegionMapper.selectAreaCode(regionId);
                String vehicleLicenseColor=disDictionaryMapper.selectVehicleColor(color);//车牌颜色
                jsonObject.put("vehicleLicenseColorName",vehicleLicenseColor);//车牌颜色
                jsonObject.put("regionName",regionName);//车牌颜色
            }
            return json;
    }



    @ApiOperation(value = "请求上报驾驶员身份信息接口")
    @RequestMapping(value = "/platform/reportDriverInfo",method = RequestMethod.POST)
    public JSONObject getDriverMessage(Integer platformId, Integer vehicleId,String param,HttpServletRequest request){
        boolean flag= listerUtil.getLister(request);
        if (flag==false){
            String list = "{\"code\":1009,\"msg\":\"此账号为监管员账号,不可进行操作\"}";
            return JSONObject.parseObject(list);
        }
        Map map=new HashMap();
        map.put("param",param);
        map.put("platformId",String.valueOf(platformId));//必选 平台id
        map.put("vehicleId",String.valueOf(vehicleId));//必选 车辆id
        Set<String> set = map.keySet();
        Iterator<String> it = set.iterator();
        while (it.hasNext()) {
            String str = it.next();
            if(map.get(str)==null || map.get(str) =="null"|| map.get(str)==""){
                map.remove(str);
                set = map.keySet();
                it = set.iterator();
            }
        }
        Map<String,String>headMap=new HashMap<>();
        headMap.put("clientCode",clientCode);
        String url="http://"+Ip+":"+port+"/dis/v1/platform/reportDriverInfo";
        String result=HttpClientUtils.doPost(url,headMap,map);
        JSONObject json= JSONObject.parseObject(result).getJSONObject("result");
        if (json==null){
          return JSONObject.parseObject(result);
        }
        return json;
    }


    //========上报驾驶员身份信息接口（回调接口）==============
    /*
    * platformId	平台id
    vehicleId	车辆id
    driverName	驾驶员姓名
    driverId	身份证编号
    licence	从业资格证号
    orgName	发证结构名称
    * */
    @RequestMapping(value = "/reportDriverInfo",method = RequestMethod.POST)
    @JwtIgnore
    public Response reportDriverInfo(Integer platformId,Integer vehicleId,String driverName,String driverId,String licence,String orgName){
        Response response=new Response();

        Map map=new HashMap();
        map.put("platformId",platformId);
        map.put("vehicleId",vehicleId);
        map.put("driverName",driverName);
        map.put("driverId",driverId);
        map.put("licence",licence);
        map.put("orgName",orgName);
        response.setData(map);
        response.setCode(RetCode.SUCCESS);
        response.setMsg("执行成功");
        log.info("上报驾驶员身份信息接口回调成功");
        return response;
    }
}








































